package com.link.base.base.mpconfig.controller;

import com.link.base.base.mpconfig.model.DeviceParam;
import com.link.base.base.mpconfig.service.DeviceParamService;
import com.link.core.basic.controller.BasicController;
import com.link.core.basic.service.BasicService;
import com.link.core.basic.service.BasicServiceException;
import com.link.core.basic.service.KeyGenerateService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @author: 闫有霞
 * @date: 2018-12-12
 * @comments: 门店设备参数
 */
@Controller
@RequestMapping("/link/deviceParam")
public class DeviceParamController extends BasicController<DeviceParam> {

    @Resource
    private KeyGenerateService keyGenerateService;

    @Resource
    private DeviceParamService deviceParamService;

    @Override
    public BasicService<DeviceParam> getBasicService() throws Exception {
        return deviceParamService;
    }


    @RequestMapping("queryDeviceInfoById")
    public Map<String, Object> queryDeviceInfoById(@RequestBody DeviceParam deviceParam) throws Exception {
        Map<String, Object> result = new HashMap<>();
        try {
            deviceParam = deviceParamService.queryDeviceInfoById(deviceParam);
            result.put("success", true);
            result.put("result", deviceParam);
        } catch (BasicServiceException e) {
            result.put("success", false);
            result.put("result", e.getMessage());
            result.put("detailMessage", e.getDetailMessage());
        } catch (Exception e) {
            result.put("success", false);
            result.put("result", e.getMessage());
        }
        return result;
    }
}
